// store的模块化功能

const release = {
  state: {
    releaseTitle: ['话题', '口碑', '帖子', '问答'],
    draftHtmlArr: JSON.parse(localStorage.getItem('draftHtmlArr')) || [],
    releaseHtmlArr: JSON.parse(localStorage.getItem('releaseHtmlArr')) || [],
  },
  getters: {
    testCount() {
      return 1
    },
  },
  mutations: {
    set_test_data(state, data) {
      state.publish.push(data)
    },
    // 草稿
    set_draft_html_arr(state, item) {
      state.draftHtmlArr.push(item)
    },
    set_release_html_arr(state, item) {
      state.releaseHtmlArr.push(item)
    },
    // 删除
    removeDraftItem(state, item) {
      state.draftHtmlArr.splice(
        state.draftHtmlArr.findIndex((v) => v.id === item.id),
        1
      )
    },
  },
  actions: {},
}

export default release
